package com.zillion.health.service.impl;

import com.alibaba.fastjson2.JSONObject;
import com.zillion.common.core.domain.entity.SysUser;
import com.zillion.common.core.domain.model.LoginUser;
import com.zillion.common.utils.DateUtils;
import com.zillion.common.utils.IdCardUtils;
import com.zillion.common.utils.SecurityUtils;
import com.zillion.common.utils.file.Base64Utils;
import com.zillion.common.utils.http.HttpUtils;
import com.zillion.health.domain.HealthEmployeeReserve;
import com.zillion.health.domain.HealthPersonInfo;
import com.zillion.health.domain.SelfCostReserve;
import com.zillion.health.mapper.HealthEmployeeReserveMapper;
import com.zillion.health.mapper.HealthPersonInfoMapper;
import com.zillion.health.service.IHealthEmployeeReserveService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.TimeUnit;

import static com.zillion.common.config.ZillionConfig.getProfile;

/**
 * 从业人员预约Service业务层处理
 *
 * @author zillion
 * @date 2025-06-09
 */
@Service
public class HealthEmployeeReserveServiceImpl implements IHealthEmployeeReserveService {

    private static final Logger log = LoggerFactory.getLogger(HealthEmployeeReserveServiceImpl.class);

    // 原始文件下载URL，根据实际情况修改
    private static final String FILE_DOWNLOAD_URL = "http://172.12.3.2:31510/PlugNew/platform/downloadCard.action?idCard=";

    @Autowired
    private HealthEmployeeReserveMapper healthEmployeeReserveMapper;

    @Autowired
    private HealthPersonInfoMapper healthPersonInfoMapper;

    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    /**
     * 查询从业人员预约
     *
     * @param id 从业人员预约主键
     * @return 从业人员预约
     */
    @Override
    public HealthEmployeeReserve selectHealthEmployeeReserveById(Long id) {
        return healthEmployeeReserveMapper.selectHealthEmployeeReserveById(id);
    }

    /**
     * 查询从业人员预约列表
     *
     * @param healthEmployeeReserve 从业人员预约
     * @return 从业人员预约
     */
    @Override
    public List<HealthEmployeeReserve> selectHealthEmployeeReserveList(HealthEmployeeReserve healthEmployeeReserve) {
        // 获取当前登录用户信息
        LoginUser loginUser = SecurityUtils.getLoginUser();
        SysUser user = loginUser.getUser();
        // 获取当前登录用户的部门ID
        Long deptId = user.getDeptId();
        healthEmployeeReserve.setDeptId(deptId);
        if (user.isAdmin()) {
            healthEmployeeReserve.setDeptId(null);
        }
        return healthEmployeeReserveMapper.selectHealthEmployeeReserveList(healthEmployeeReserve);
    }

    /**
     * 新增从业人员预约
     *
     * @param healthEmployeeReserve 从业人员预约
     * @return 结果
     */
    @Override
    public int insertHealthEmployeeReserve(HealthEmployeeReserve healthEmployeeReserve) {
        healthEmployeeReserve.setCreateTime(DateUtils.getNowDate());
        return healthEmployeeReserveMapper.insertHealthEmployeeReserve(healthEmployeeReserve);
    }

    /**
     * 插入自费预约人员数据
     *
     * @param selfCostReserve 自费预约人员数据
     * @return 插入结果
     */
    @Override
    public int insertHealthSelfCostReserve(SelfCostReserve selfCostReserve) {
        HealthPersonInfo personalInfo = getPersonalInfo(selfCostReserve);
        HealthEmployeeReserve employeeReserve = getHealthEmployeeReserve(selfCostReserve);
        int i = healthPersonInfoMapper.insertHealthPersonInfo(personalInfo);
        int row = 0;
        if (i > 0) {
            row = healthEmployeeReserveMapper.insertHealthEmployeeReserve(employeeReserve);
        }
        return row;
    }

    @Override
    public List<HealthEmployeeReserve> loadSyncExpireReserveData() {
        return healthEmployeeReserveMapper.loadSyncExpireReserveData();
    }

    // 获取自费预约人员数据
    private static HealthPersonInfo getPersonalInfo(SelfCostReserve selfCostReserve) {
        HealthPersonInfo personInfo = new HealthPersonInfo();
        personInfo.setName(selfCostReserve.getName()); // 申报姓名
        String idCard = selfCostReserve.getIdCard();
        personInfo.setIdCard(idCard);// 身份证号
        String birthday = IdCardUtils.extractBirthday(idCard);
        personInfo.setAge(IdCardUtils.calculateAge(birthday)); // 年龄
        personInfo.setGender(IdCardUtils.extractGender(idCard));// 性别

        personInfo.setPhone(selfCostReserve.getPhone()); // 手机号
        personInfo.setAddress(selfCostReserve.getAddress());//  地址
        personInfo.setEthnic(selfCostReserve.getEthnic());// 民族
        Integer isUnit = selfCostReserve.getIsUnit();// 是否单位
        personInfo.setIsUnit(isUnit);
        if (isUnit == 1) {
            personInfo.setUnitName(selfCostReserve.getUnitName());// 单位名称
            personInfo.setSocialCreditCode(selfCostReserve.getSocialCreditCode());// 社会信用代码
        }
        personInfo.setApplyTime(DateUtils.getNowDate());// 申请时间
        personInfo.setJobTypeId(selfCostReserve.getJobTypeId());// 从业人员类型
        personInfo.setParkId(100); // 园区id
        personInfo.setAuditStatus(1); // 自费无需申报审核,直接审核通过
        return personInfo;
    }

    // 获取自费预约人员数据
    private static HealthEmployeeReserve getHealthEmployeeReserve(SelfCostReserve selfCostReserve) {
        HealthEmployeeReserve employeeReserve = new HealthEmployeeReserve();
        employeeReserve.setName(selfCostReserve.getName());// 预约姓名
        employeeReserve.setIdCard(selfCostReserve.getIdCard());// 身份证号
        employeeReserve.setPhone(selfCostReserve.getPhone());// 手机号
        employeeReserve.setReserveHospital(selfCostReserve.getReserveHospital());// 预约医院
        employeeReserve.setReserveDate(selfCostReserve.getReserveDate());// 预约日期
        employeeReserve.setReserveHour(selfCostReserve.getReserveHour());// 预约时间
        employeeReserve.setIsUnit(selfCostReserve.getIsUnit());// 是否单位
        if (1 == selfCostReserve.getIsUnit()) {
            employeeReserve.setUnitName(selfCostReserve.getUnitName());// 单位名称
            employeeReserve.setSocialCreditCode(selfCostReserve.getSocialCreditCode());// 社会信用代码
        }
        employeeReserve.setReserveType(1);// 预约类型
        employeeReserve.setTjStatus(0);// 体检状态,默认已预约
        employeeReserve.setQualify(0);// 体检是否合格,默认-
        employeeReserve.setCreateTime(DateUtils.getNowDate());
        return employeeReserve;
    }

    /**
     * 修改从业人员预约
     *
     * @param healthEmployeeReserve 从业人员预约
     * @return 结果
     */
    @Override
    public int updateHealthEmployeeReserve(HealthEmployeeReserve healthEmployeeReserve) {
        return healthEmployeeReserveMapper.updateHealthEmployeeReserve(healthEmployeeReserve);
    }

    /**
     * 批量删除从业人员预约
     *
     * @param ids 需要删除的从业人员预约主键
     * @return 结果
     */
    @Override
    public int deleteHealthEmployeeReserveByIds(Long[] ids) {
        return healthEmployeeReserveMapper.deleteHealthEmployeeReserveByIds(ids);
    }

    /**
     * 删除从业人员预约信息
     *
     * @param id 从业人员预约主键
     * @return 结果
     */
    @Override
    public int deleteHealthEmployeeReserveById(Long id) {
        return healthEmployeeReserveMapper.deleteHealthEmployeeReserveById(id);
    }

    /**
     * 查询到期的预约数据ID
     *
     * @return 预约数据ID列表
     */
    @Override
    public List<Long> selectEmployeeExpireReserveDataId() {
        return healthEmployeeReserveMapper.selectEmployeeExpireReserveDataId();
    }

    /**
     * 查询推送到体检系统的预约数据
     *
     * @return 预约数据ID列表
     */
    @Override
    public List<HealthEmployeeReserve> selectEmployeeReserveToExamData() {
        return healthEmployeeReserveMapper.selectEmployeeReserveToExamData();
    }

    /**
     * 修改指定ID的预约数据的状态
     *
     * @param ids 预约数据ID列表
     * @return 影响行数
     */
    @Override
    public int updateEmployeeReserveTjStatus(List<Long> ids) {
        return healthEmployeeReserveMapper.updateEmployeeReserveTjStatus(ids);
    }

    /**
     * 修改指定ID的预约数据的推送状态
     *
     * @param ids 预约数据ID列表
     * @return 影响行数
     */
    @Override
    public int updateEmployeeReserveIsPush(List<Long> ids) {
        return healthEmployeeReserveMapper.updateEmployeeReserveIsPush(ids);
    }

    @Override
    public int updateEmployeeReserveIsPushExpireData(List<Long> ids) {
        return healthEmployeeReserveMapper.updateEmployeeReserveIsPush(ids);
    }

    /**
     * 批量修改指定ID的预约数据的推送状态
     *
     * @param ids 预约数据ID列表
     * @return 影响行数
     */
    @Override
    public HashMap<String, String> updateIsSendCard(Long[] ids) {
        // 返回结果
        HashMap<String, String> resultMap = new HashMap<>();

        // 用来存储成功上传证件数据的id
        List<Long> successIds = new ArrayList<>();

        // 先根据id查询到所有需要发证的人
        List<HealthEmployeeReserve> healthEmployeeReserves = healthEmployeeReserveMapper.selectHealthEmployeeReserveByIds(ids);
        // 返回结果处理
        String retCode = "";
        String message = "";
        if (!healthEmployeeReserves.isEmpty()) {
            for (HealthEmployeeReserve healthEmployeeReserve : healthEmployeeReserves) {
                // 获取预约人员id
                Long employeeReserveId = healthEmployeeReserve.getId();
                // 获取健康证编号
                String certificateNumber = getCertificateNumber(employeeReserveId);
                // 获取调用入参
                JSONObject jsonParam = getJsonObject(healthEmployeeReserve, certificateNumber);
                log.info("--调用省政府接口参数:{}", jsonParam);
                // 请求URL--注意:url先访问中转服务器再访问省政府的接口去提交证件数据
                String url = "http://172.12.3.2:31510/PlugNew/platform/sendCard.action";
                // 发送POST请求
                String param = jsonParam.toJSONString();
                log.info("请求param:{}", param);
                String response = HttpUtils.sendPost(url, param, "application/json");
                JSONObject jsonObject = JSONObject.parseObject(response);
                retCode = jsonObject.getJSONObject("data").getString("retCode");
                if ("FAILED".equals(retCode)) {
                    message = jsonObject.getJSONObject("data").getJSONObject("errors").getString("message");
                    log.error("预约人员{}调用接口返回错误信息:{}", employeeReserveId, message);
                } else if ("SUCCESS".equals(retCode)) {
                    // 请求成功则把当前预约人员的id添加到成功列表中
                    successIds.add(employeeReserveId);
                    // 成功的才修改发证状态,否则不修改
                    log.info("接口返回成功!");
                }
                // 更改发证状态
                if (!successIds.isEmpty()) {
                    healthEmployeeReserveMapper.updateIsSendCard(successIds);
                } else {
                    log.info("[无成功的上传证件数据]");
                }
            }
        }else{
            retCode = "FAILED";
            message = "暂无发证数据或发证人员已上传发证数据";
            log.info("[暂无发证数据或发证人员已上传发证数据]");
        }
        resultMap.put("status", retCode);
        resultMap.put("msg", message);
        return resultMap;
    }

    /**
     * 下载证件
     *
     * @param id 下载证件人员数据id
     * @return 文件下载URL
     */
    @Override
    public String downloadCard(String id) {
        // 通过id拿到预约人员数据
        HealthEmployeeReserve healthEmployeeReserve = healthEmployeeReserveMapper.selectHealthEmployeeReserveById(Long.valueOf(id));
        String idCard = healthEmployeeReserve.getIdCard();
        String certificateNumber = healthEmployeeReserve.getCertificateNumber().toString();

        /*1.先从远程PlugNew中把文件下载到服务器*/
        // 构建完整的文件下载链接
        String fullUrl = FILE_DOWNLOAD_URL + idCard + "&certificateNumber="+certificateNumber;
        log.info("请求中转服务器下载文件URL: {}", fullUrl);
        // 获取当前年份
        int currentYear = LocalDate.now().getYear();

        // 指定文件在服务器上的保存路径
        // E:\zillion\ uploadPath\certificate\2025
        String saveFilePath = getProfile() + "/certificate/" + currentYear;
        log.info("文件保存路径: {}", saveFilePath);
        // 创建文件夹（如果不存在）
        File file = new File(saveFilePath);
        if (!file.exists()) {
            boolean success = file.mkdirs();
            if (!success) {
                log.error("创建目录失败: {}", file.getAbsolutePath());
                throw new RuntimeException("无法创建文件保存目录");
            }
        }
        // 健康证的完整路径
        String path = saveFilePath + "/" + idCard + ".ofd";

        // 判断文件是否存在
        File isFile = new File(path);
        if (!isFile.exists()) {
            log.info("文件不存在，开始下载: {}", path);
            downloadFile(fullUrl, path); // 调用下载方法
        } else {
            log.info("文件已存在，无需重复下载: {}", path);
        }

        /*2.返回相对路径（前端可通过统一接口访问）*/
        // downloadFileToClient(saveFilePath, response);
        return path.replace(getProfile(), "");
    }

    @Override
    public int syncTjStatus(HealthEmployeeReserve healthEmployeeReserve) {
        // 先查询平台是否有此人
        List<HealthEmployeeReserve> healthEmployeeReserves = healthEmployeeReserveMapper.selectHealthEmployeeReserveByIdCardAndReserveDate(healthEmployeeReserve);
        if (!healthEmployeeReserves.isEmpty()) {
            return healthEmployeeReserveMapper.syncTjStatus(healthEmployeeReserve);
        }else{
            log.info("无此用户");
            return 0;
        }
    }

    /**
     * 下载文件到客户端
     *
     * @param filePath 文件路径
     * @param response 响应对象
     */
    public void downloadFileToClient(String filePath, HttpServletResponse response) {
        File file = new File(filePath);
        log.info("准备向用户发送文件: {}, 大小: {} KB", filePath, file.length() / 1024);

        if (!file.exists()) {
            log.error("文件不存在: {}", filePath);
            response.setStatus(HttpServletResponse.SC_NOT_FOUND);
            return;
        }

        // 设置响应头
        try {
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment; filename=\"" + URLEncoder.encode(file.getName(), "UTF-8") + "\"");
            response.setContentLengthLong(file.length());
        } catch (UnsupportedEncodingException e) {
            log.error("编码错误", e);
            throw new RuntimeException(e);
        }

        // 写入文件流
        try (InputStream in = Files.newInputStream(file.toPath());
             OutputStream out = response.getOutputStream()) {

            byte[] buffer = new byte[4096];
            int bytesRead;
            while ((bytesRead = in.read(buffer)) != -1) {
                out.write(buffer, 0, bytesRead);
            }
            out.flush();
        } catch (IOException e) {
            log.error("文件下载错误", e);
            throw new RuntimeException(e);
        }
    }


    /**
     * 从中转服务器中下载文件到服务器
     *
     * @param fileUrl      文件URL
     * @param saveFilePath 文件保存路径
     */
    public static void downloadFile(String fileUrl, String saveFilePath) {
        try {
            URL url = new URL(fileUrl);
            HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
            httpConn.setRequestMethod("GET");

            int responseCode = httpConn.getResponseCode();
            // 确保响应正常
            if (responseCode == HttpURLConnection.HTTP_OK) {
                try (InputStream inputStream = httpConn.getInputStream();
                     OutputStream outputStream = Files.newOutputStream(Paths.get(saveFilePath))) {
                    byte[] buffer = new byte[4096];
                    int bytesRead;
                    while ((bytesRead = inputStream.read(buffer)) != -1) {
                        outputStream.write(buffer, 0, bytesRead);
                    }
                    System.out.println("文件下载完成: " + saveFilePath);
                }
            } else {
                System.out.println("下载失败，响应码: " + responseCode);
            }

            httpConn.disconnect();
        } catch (IOException e) {
            log.error("下载文件失败", e);
        }
    }

    /**
     * 生成唯一的健康证编号
     *
     * @param employeeReserveId 当前预约记录ID，用于更新数据库中的健康证编号
     * @return 唯一的健康证编号
     * @Description: 编号规则：由当前年份 + 6位递增序列号组成（如：2025000008）
     * 使用 Redis 原子操作保证在分布式环境下的唯一性和顺序性
     */
    private String getCertificateNumber(Long employeeReserveId) {
        // 获取当前日期并提取年份
        LocalDate now = LocalDate.now();
        String currentYear = String.valueOf(now.getYear());

        // 在数据库中查询健康证标号
        String loadCertificateNumber = healthEmployeeReserveMapper.loadCertificateNumber(employeeReserveId);
        if (loadCertificateNumber != null && !loadCertificateNumber.isEmpty() && loadCertificateNumber.length() == 8) {
            // 如果数据库中存在健康证标号，则直接返回
            return loadCertificateNumber;
        }else { // 如果不存在,就用redis生成并写入数据库
            // 创建Key，按年份分段存储序号，实现每年从 000001 开始递增
            String redisKey = "cert_seq:" + currentYear;
            // 判断当前年份的 key 是否存在
            Boolean hasKey = redisTemplate.hasKey(redisKey);
            // 使用 Redis的原子自增命令 INCR 实现线程安全且分布式的序号生成
            Long seq;
            if (Boolean.TRUE.equals(hasKey)) {
                seq = redisTemplate.opsForValue().increment(redisKey, 1);
            } else {
                // 设置默认值为 8，并设置一年有效期
                redisTemplate.opsForValue().setIfAbsent(redisKey, "8", 365, TimeUnit.DAYS);
                seq = 8L;
            }
            // 拼接最终的健康证编号：年份 + 6位补零的序号
            String certificateNumber = currentYear + String.format("%06d", seq);
            // 将生成的编号写入数据库，确保后续业务可以追溯和去重
            healthEmployeeReserveMapper.updateCertificateNumber(certificateNumber, employeeReserveId);
            return certificateNumber;
        }

//        // !生成健康证编号!
//        // 获取最大的健康证编号
//        String certificateNumber = "";
//        String maxCertificateNumber = String.valueOf(healthEmployeeReserveMapper.selectMaxCertificateNumber());
//        if (!maxCertificateNumber.isEmpty()) {
//            LocalDate now = LocalDate.now();
//            String currentYear = String.valueOf(now.getYear()); // 年份部分
//            // 下一个序列号
//            int nextSeq = 1;
//            if (maxCertificateNumber.length() >= 6) {
//                try {
//                    // 取出前4位判断是否为今年
//                    String dbYear = maxCertificateNumber.substring(0, 4);
//                    if (dbYear.equals(currentYear)) {
//                        // 是同一年，继续递增
//                        int lastSeq = Integer.parseInt(maxCertificateNumber.substring(4)); // 取后面部分
//                        nextSeq = lastSeq + 1;
//                    } else {
//                        // 跨年了，重置为1
//                        nextSeq = 1;
//                    }
//                } catch (Exception e) {
//                    log.error("生成健康证编号异常", e);
//                }
//            }
//            // 拼接新的编号：年份 + 6位自增数（不足补零）
//            certificateNumber = currentYear + String.format("%06d", nextSeq);
//        } else {
//            certificateNumber = "2025000008";
//        }
//        // 将生成的编号写回数据库（防止重复）
//         healthEmployeeReserveMapper.updateCertificateNumber(employeeReserveId, certificateNumber);
//        return certificateNumber;
    }

    /**
     * 获取调用接口入参
     *
     * @param employeeMap       预约人员信息
     * @param certificateNumber 健康证编号
     * @return JSONObject 调用接口入参
     */
    private static JSONObject getJsonObject(HealthEmployeeReserve employeeMap, String certificateNumber) {
        // 获取当前日期
        LocalDate currentDate = LocalDate.now();
        // 获取当前日期和一年后的日期
        LocalDate oneYearLater = currentDate.plusYears(1);
        // 定义格式
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        // 格式化输出
        String now = currentDate.format(formatter);

        // 标*的参数都是需要动态获取的
        JSONObject metaData = new JSONObject();
        metaData.put("certypeDtlId", "B11566A60B2A4CEDAB5AD89136B27429"); // 证照明细编码
        metaData.put("certypeDtlName", "健康证（兰州新区新）"); // 证照模板名称
        metaData.put("certificateNumber", certificateNumber); // *健康证编号
        metaData.put("issueDept", " 兰州新区教育和卫生健康委员会(疾病和预防控制局)"); // 证照颁发机构-固定值
        metaData.put("issueDeptCode", "11620000067205713F"); // 证照颁发机构代码-固定值
        metaData.put("certificateAreaCode", "627100000000"); // 区划代码
        metaData.put("certificateAreaName", "兰州新区"); // 区划名称
        metaData.put("issueDate", now); // *颁发日期
        metaData.put("certificateHolder", employeeMap.getName()); // *持有者姓名
        metaData.put("certificateHolderCode", employeeMap.getIdCard()); // *持有者身份证件号码
        metaData.put("certificateHolderType", "111"); // 持有者证件类型-固定值
        metaData.put("certificateHolderCategory", "1"); // 持有者类型-固定值
        metaData.put("validityStart", now); // *有效期开始
        metaData.put("validityEnd", oneYearLater); // *有效期截止
        metaData.put("remark", "提交健康证证照数据和证照"); // 备注

        // 构建 surfaceData 对象
        JSONObject surfaceData = new JSONObject();
        surfaceData.put("KZ_XingMing", employeeMap.getName()); // *姓名
        surfaceData.put("KZ_ShenFenZhengHao", employeeMap.getIdCard()); // *身份证号
        surfaceData.put("KZ_FaZhengRiQi", now); // *发证日期

        // 获取作业类别
        String jobTypeName = getJobTypeName(employeeMap);

        surfaceData.put("KZ_ZuoYeLeiBie", jobTypeName); // *作业类别-这个有平台字典提供
        surfaceData.put("KZ_YouXiaoQiXian", oneYearLater); // *有限日期
        surfaceData.put("KZ_FaZhengJiGou", "兰州新区教育和卫生健康委员会(疾病和预防控制局)"); // 发证机构-固定值
        surfaceData.put("KZ_BianHao", certificateNumber); // *健康证编号
        // 获取体检报告二维码
//        surfaceData.put("KZ_ErWeiMa", "http://ip:port/newPackageAction/totalReportShow_toTotalReportzjhmShowJsp.action?zjhm=" + employeeMap.getIdCard()); // *报告二维码
        // http://117.157.64.139:9100/ + profile/upload/2025/07/14/%E5%86%89%E6%A1%90_20250714154212A842.jpg
        surfaceData.put("KZ_ErWeiMa", "http://117.157.64.139:9100" + employeeMap.getTjResult()); // *报告二维码

        // 获取证件照片
        String avatarPath = employeeMap.getEmployeeAvatar();
        // 获取图片完整路径
        String avatar = (getProfile() + avatarPath).replace("profile/", "");
        String avatarBase64 = Base64Utils.convertImageToBase64(avatar);
        surfaceData.put("KZ_ZhaoPian", avatarBase64); // *身份证件的照片

        // 构建根对象
        JSONObject bodyJson = new JSONObject();
        bodyJson.put("type", "new");
        bodyJson.put("autoSeal", "false");
        bodyJson.put("metaData", metaData);
        bodyJson.put("surfaceData", surfaceData);
        return bodyJson;
    }

    /**
     * 根据作业类别ID获取作业类别名称
     *
     * @param employeeMap 预约数据
     * @return 作业类别名称
     */
    private static String getJobTypeName(HealthEmployeeReserve employeeMap) {
        String jobTypeId = employeeMap.getJobType();
        String jobTypeName = "";
        if ("1".equals(jobTypeId)) {
            jobTypeName = "食品";
        } else if ("2".equals(jobTypeId)) {
            jobTypeName = "药品";
        } else if ("3".equals(jobTypeId)) {
            jobTypeName = "化妆品生产";
        } else if ("4".equals(jobTypeId)) {
            jobTypeName = "公共场所";
        } else if ("5".equals(jobTypeId)) {
            jobTypeName = "生活饮用水";
        } else if ("6".equals(jobTypeId)) {
            jobTypeName = "消毒产品";
        }
        return jobTypeName;
    }
}
